<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:clb="clr-namespace:WPFDeveloperTools.Controls.CheckedListBox"
    xmlns:ftb="clr-namespace:WPFDeveloperTools.Controls.FilteredTextBox"
    xmlns:cp="clr-namespace:WPFDeveloperTools.Controls.CollapsiblePanel"
    xmlns:ccb="clr-namespace:WPFDeveloperTools.Controls.CheckedComboBox"
    xmlns:rtb="clr-namespace:WPFDeveloperTools.Controls.RichTextBoxWithToolBar"
    xmlns:graph="clr-namespace:WPFDeveloperTools.Controls.Graph"
    xmlns:cbfs="clr-namespace:WPFDeveloperTools.Controls.ComboBoxFontSelection"
    >

  <!--
    CheckedListBox: Based on RadioButtonList by Kevin Moore
  -->
  <Style x:Key="{x:Type clb:CheckedListBox}" TargetType="{x:Type clb:CheckedListBox}" BasedOn="{StaticResource {x:Type ListBox}}">
    <Setter Property="HorizontalAlignment" Value="Center"/>
    <Setter Property="VerticalAlignment" Value="Center"/>
    <Setter Property="BorderBrush" Value="Transparent"/>
    <Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Cycle"/>
    <Setter Property="ItemContainerStyle">
      <Setter.Value>
        <Style TargetType="{x:Type ListBoxItem}" >
          <Setter Property="Margin" Value="2, 2, 2, 0" />
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="{x:Type ListBoxItem}">
                <Border Background="Transparent">
                  <CheckBox Content="{TemplateBinding Content}"/>
                </Border>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </Setter.Value>
    </Setter>
  </Style>
  

  <!--
    FilteredTextBox
  -->
  <Style x:Key="{x:Type ftb:FilteredTextBox}" TargetType="{x:Type ftb:FilteredTextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
    <Setter Property="Margin" Value="1"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ftb:FilteredTextBox}">
          <StackPanel Orientation="Horizontal">
            <TextBlock Text="{TemplateBinding LabelInfo}" Margin="0,2,2,0" />
            <Border Background="{TemplateBinding Background}" x:Name="Bd" SnapsToDevicePixels="True" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
              <ScrollViewer Width="145" x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
            </Border>
          </StackPanel>
          <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
              <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" TargetName="Bd" />
              <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>


  <!--
    CollapsiblePanel
  -->
  <Style x:Key="{x:Type cp:CollapsiblePanel}" TargetType="{x:Type cp:CollapsiblePanel}" BasedOn="{StaticResource {x:Type Expander}}">
    <Setter Property="ContentTemplate">
      <Setter.Value>
        <DataTemplate DataType="{x:Type cp:CollapsiblePanel}">
          <TextBlock Width="Auto" Height="Auto" x:Name="TextBlock" TextWrapping="Wrap" Text="{Binding Path=InfoToShow, RelativeSource={RelativeSource AncestorType={x:Type cp:CollapsiblePanel}}}" />
        </DataTemplate>
      </Setter.Value>
    </Setter>
  </Style>


  <!--
    CheckedComboBox
  -->  
  <Style x:Key="{x:Type ccb:CheckedComboBox}" TargetType="{x:Type ccb:CheckedComboBox}" BasedOn="{StaticResource {x:Type ComboBox}}">
    <Setter Property="ItemContainerStyle">
      <Setter.Value>
        <Style TargetType="{x:Type ComboBoxItem}" >
          <Setter Property="Margin" Value="2, 2, 2, 0" />
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                <Border Background="Transparent" x:Name="borderSelect">
                  <CheckBox Content="{TemplateBinding Content}" x:Name="chkSelect" />
                </Border>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </Setter.Value>
    </Setter>
  </Style>


  <!--
    RichTextBoxWithToolBar
  -->
  <Style x:Key="{x:Type rtb:RichTextBoxWithToolBar}" TargetType="{x:Type rtb:RichTextBoxWithToolBar}" BasedOn="{StaticResource {x:Type RichTextBox}}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type rtb:RichTextBoxWithToolBar}">
          <Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
            <StackPanel>
              <DockPanel x:Name="DockPanelToolBar" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" LastChildFill="False">
                <ToolBar DockPanel.Dock="Top">
                  <Button x:Name="btnBold" ToolTip="Bold" Width="20" Content="B" Command="EditingCommands.ToggleBold"/>
                  <Button Width="20" Content="U" Command="EditingCommands.ToggleUnderline" x:Name="btnUnderline" ToolTip="Underline" Height="21.96"/>
                  <Button Width="20" Content="I" Command="EditingCommands.ToggleItalic" Height="21.96" x:Name="btnItalic" ToolTip="Italic"/>
                  <Separator RenderTransformOrigin="0.5,0.5" Width="30" Height="1">
                    <Separator.RenderTransform>
                      <TransformGroup>
                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                        <SkewTransform AngleX="0" AngleY="0"/>
                        <RotateTransform Angle="-90"/>
                        <TranslateTransform X="0" Y="0"/>
                      </TransformGroup>
                    </Separator.RenderTransform>
                  </Separator>
                  <Button Width="40" Content="Undo" Command="ApplicationCommands.Undo" Height="21.96" x:Name="btnUndo" ToolTip="Undo"/>
                  <Button Width="40" Content="Redo" Command="ApplicationCommands.Redo" Height="21.96" x:Name="btnRedo" ToolTip="Redo" RenderTransformOrigin="-0.262,-1.408"/>
                  <Separator RenderTransformOrigin="0.5,0.5" Width="30" Height="1">
                    <Separator.RenderTransform>
                      <TransformGroup>
                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                        <SkewTransform AngleX="0" AngleY="0"/>
                        <RotateTransform Angle="-90"/>
                        <TranslateTransform X="0" Y="0"/>
                      </TransformGroup>
                    </Separator.RenderTransform>
                  </Separator>
                  <Button x:Name="btnDecrease" ToolTip="Decrease Indentation" Width="20" Content="De" Command="EditingCommands.DecreaseIndentation" RenderTransformOrigin="3.475,-1.909" Height="21.96"/>
                  <Button x:Name="btnIncrease" ToolTip="Increase Indentation" Width="20" Content="In" Command="EditingCommands.IncreaseIndentation" RenderTransformOrigin="3.475,-1.909" Height="21.96"/>
                </ToolBar>
              </DockPanel>
              <Separator Height="5" Width="{TemplateBinding Width}"/>
              <ScrollViewer SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ContentHost"/>
            </StackPanel>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
              <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!--
    Graph
  -->
  <Style x:Key="{x:Type graph:Graph}" TargetType="{x:Type graph:Graph}" BasedOn="{StaticResource {x:Type ItemsControl}}">
    <Style.Triggers>
      <!-- Orientation Vertical -->
      <Trigger Property="GraphOrientation" Value="Vertical">
        <Setter Property="ItemTemplate">
          <Setter.Value>
            <DataTemplate>
              <Rectangle HorizontalAlignment="Left" Width="{Binding}" Height="25" Fill="Red" Margin="0,5,0,5"/>
            </DataTemplate>
          </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
          <Setter.Value>
            <ItemsPanelTemplate>
              <StackPanel Orientation="Vertical" />
            </ItemsPanelTemplate>
          </Setter.Value>
        </Setter>
      </Trigger>

      <!-- Orientation Horizontal -->
      <Trigger Property="GraphOrientation" Value="Horizontal">
        <Setter Property="ItemTemplate">
          <Setter.Value>
            <DataTemplate>
              <Rectangle VerticalAlignment="Bottom" Width="25" Height="{Binding}" Fill="Red" Margin="5,0,5,0"/>
            </DataTemplate>
          </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
          <Setter.Value>
            <ItemsPanelTemplate>
              <StackPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>
          </Setter.Value>
        </Setter>
      </Trigger>
    </Style.Triggers>

    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate>
          <Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
            <StackPanel Orientation="Vertical">
              <TextBlock Text="{Binding Path=Legend, RelativeSource={RelativeSource AncestorType={x:Type graph:Graph}}}" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,0,20" />
              <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
            </StackPanel>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!--
    ComboBoxFontSelection
  -->
  <Style x:Key="{x:Type cbfs:ComboBoxFontSelection}" TargetType="{x:Type cbfs:ComboBoxFontSelection}" BasedOn="{StaticResource {x:Type ComboBox}}">
    <Setter Property="ItemsPanel">
      <Setter.Value>
        <ItemsPanelTemplate>
          <VirtualizingStackPanel IsVirtualizing="True"/>
        </ItemsPanelTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>